package org.goyo.main.domain.entity.base;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.goyo.main.domain.entity.BaseObject;
import org.goyo.main.domain.entity.system.SysUser;
import org.hibernate.annotations.Type;
/**
 * 客户
 * 
 * @author chenchuan
 * 2014年11月5日
 */
@Entity
@Table(uniqueConstraints={@UniqueConstraint(columnNames={"number"})})
public class Customer extends BaseObject  implements Serializable {

	private static final long serialVersionUID = 1L;
	//单据编号前缀
	public static final String BIZTYPE = "KF";
	/**
	 * 类型
	 */
	public static final String TYPE = "CUSTOMER";
	
	/**
	 * 业务分析码	
	 */
	@Column
	private String businessNum;
	/**
	 * 内部客户	
	 */
	@Column
	private String inerCustomer;
	/**
	 * 内部公司	
	 */
	@Column
	private String inerCompany;
	/**
	 * 客户	/分类
	 */
	@ManyToOne
    @JoinColumn(name="customerProperId")
	private CustomerClassification customerProper;
	/**
	 * 上级客户	
	 */
	/*@ManyToOne
    @JoinColumn(name="superCustomerId")
	private Customer superCustomer;*/
	
	
	/**
	 * 所属客户经理
	 */
	@ManyToOne
    @JoinColumn(name="subCustomerManagerId")
	private SysUser subCustomerManager;
	
	
	   /**
     * 客户性质  个人/企业
     */
	@Column
    private String customerNature;
	
	/**
	 * 工商注册号	
	 */
	@Column
	private String industrialNum;
	/**
	 * 法人代表	
	 */
	@Column
	private String legalPerson;
	/**
	 * 营业执照	
	 */
	@Column
	private String tradingNum;
	/**
	 * 经营许可证	
	 */
	@Column
	private String manageNum;
	
	/***
	 * 个人姓名
	 */
	@Column
	private String personalName;
	/**
	 * 个人电话
	 */
	@Column
	private String personalPhone;
	
	/**
	 * 手机
	 */
	@Column
	private String personalMobilePhone;
	/**
	 * qq
	 */
	@Column
	private String qq;
	/**
	 * 微信
	 */
	@Column
	private String weChat;
	/**
	 * 是否为会员
	 */
	@Column
	@Type(type="boolean")
	private Boolean whetherVip;
	/**
	 * vip号码
	 */
	@Column
	private String vipNumber;
	/***
	 * 个人邮箱
	 */
	@Column
	private String personalEmail;
	/***
	 * 个人身份证
	 */
	@Column
	private String personalIdcard;
	/**
	 * 行业	
	 */
	@Column
	private String industry;
	/**
	 * 邮政编码	
	 */
	@Column
	private String zipCode;
	/**
	 * 开票类型
	 */
	@Column
	private String makeType;
	/**
	 * 税率	
	 */
	@Column
	private String taxRate;
	/**
	 * 税种	
	 */
	@Column
	private String taxType;
	/**
	 * 国家	
	 */
	@Column
	private String country;
	/**
	 * 省份	
	 */
	@Column
	private String province;
	/**
	 * 城市	
	 */
	@Column
	private String city;
	/**
	 * 区县	
	 */
	@Column
	private String district;
	/**
	 * 地址
	 */
	@Column
	private String 	address;
	
	/**
	 * 财务资料
	 */
	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="financeId")
	private CustomerFinance finance;
	
	/**
	 * 销售资料
	 */
	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="saleId")
	private CustomerSale sale;
	
	@OneToMany(cascade={CascadeType.ALL})
	@JoinColumn(name="parent_id")
	private List<ContactsEntry> entrys = new ArrayList<ContactsEntry>();
	
	
	public String getBusinessNum() {
		return businessNum;
	}
	public void setBusinessNum(String businessNum) {
		this.businessNum = businessNum;
	}
	public String getInerCustomer() {
		return inerCustomer;
	}
	public void setInerCustomer(String inerCustomer) {
		this.inerCustomer = inerCustomer;
	}
	public String getInerCompany() {
		return inerCompany;
	}
	public void setInerCompany(String inerCompany) {
		this.inerCompany = inerCompany;
	}
	
	public CustomerClassification getCustomerProper() {
    return customerProper;
  }
  public void setCustomerProper(CustomerClassification customerProper) {
    if(customerProper != null &&("".equals(customerProper.getUuid()) || customerProper.getUuid()==null))
      this.customerProper = null;
  else
      this.customerProper = customerProper;
  }
/*  public Customer getSuperCustomer() {
    return superCustomer;
  }
  public void setSuperCustomer(Customer superCustomer) {
    if(superCustomer != null &&("".equals(superCustomer.getUuid()) || superCustomer.getUuid()==null))
      this.superCustomer = null;
  else
      this.superCustomer = superCustomer;
  }*/
  
  public String getIndustrialNum() {
		return industrialNum;
	}
	public SysUser getSubCustomerManager() {
    return subCustomerManager;
  }
  public void setSubCustomerManager(SysUser subCustomerManager) {
    if(subCustomerManager != null && ("".equals(subCustomerManager.getUuid()) || subCustomerManager.getUuid() == null)){
      this.subCustomerManager = null;
    }else{
      this.subCustomerManager = subCustomerManager;      
    }
  }
  public void setIndustrialNum(String industrialNum) {
		this.industrialNum = industrialNum;
	}
	public String getLegalPerson() {
		return legalPerson;
	}
	public void setLegalPerson(String legalPerson) {
		this.legalPerson = legalPerson;
	}
	public String getTradingNum() {
		return tradingNum;
	}
	public void setTradingNum(String tradingNum) {
		this.tradingNum = tradingNum;
	}
	public String getManageNum() {
		return manageNum;
	}
	public void setManageNum(String manageNum) {
		this.manageNum = manageNum;
	}
	public String getIndustry() {
		return industry;
	}
	public void setIndustry(String industry) {
		this.industry = industry;
	}
	public String getZipCode() {
		return zipCode;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	public String getMakeType() {
		return makeType;
	}
	public void setMakeType(String makeType) {
		this.makeType = makeType;
	}
	public String getTaxRate() {
		return taxRate;
	}
	public void setTaxRate(String taxRate) {
		this.taxRate = taxRate;
	}
	public String getTaxType() {
		return taxType;
	}
	public void setTaxType(String taxType) {
		this.taxType = taxType;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getDistrict() {
		return district;
	}
	public void setDistrict(String district) {
		this.district = district;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public CustomerFinance getFinance() {
		return finance;
	}
	public void setFinance(CustomerFinance finance) {
		this.finance = finance;
	}
	public CustomerSale getSale() {
		return sale;
	}
	public void setSale(CustomerSale sale) {
		this.sale = sale;
	}
  public String getCustomerNature() {
    return customerNature;
  }
  public void setCustomerNature(String customerNature) {
    this.customerNature = customerNature;
  }
  public List<ContactsEntry> getEntrys() {
    return entrys;
  }
  public void setEntrys(List<ContactsEntry> entrys) {
    this.entrys = entrys;
  }
  public String getPersonalName() {
    return personalName;
  }
  public void setPersonalName(String personalName) {
    this.personalName = personalName;
  }
  public String getPersonalPhone() {
    return personalPhone;
  }
  public void setPersonalPhone(String personalPhone) {
    this.personalPhone = personalPhone;
  }
  public String getPersonalEmail() {
    return personalEmail;
  }
  public void setPersonalEmail(String personalEmail) {
    this.personalEmail = personalEmail;
  }
  public String getPersonalIdcard() {
    return personalIdcard;
  }
  public void setPersonalIdcard(String personalIdcard) {
    this.personalIdcard = personalIdcard;
  }
  public String getPersonalMobilePhone() {
    return personalMobilePhone;
  }
  public void setPersonalMobilePhone(String personalMobilePhone) {
    this.personalMobilePhone = personalMobilePhone;
  }
  public String getQq() {
    return qq;
  }
  public void setQq(String qq) {
    this.qq = qq;
  }
  public String getWeChat() {
    return weChat;
  }
  public void setWeChat(String weChat) {
    this.weChat = weChat;
  }
  public Boolean getWhetherVip() {
    return whetherVip;
  }
  public void setWhetherVip(Boolean whetherVip) {
    this.whetherVip = whetherVip;
  }
  public String getVipNumber() {
    return vipNumber;
  }
  public void setVipNumber(String vipNumber) {
    this.vipNumber = vipNumber;
  }
	
}
